const obj = {
  '1d2bdbfe627941b6917b6e3079ca5e17': {
    片区入库新增: 'projectUpdate::inventoryReview::area::add',
    片区入库编辑: 'projectUpdate::inventoryReview::area::edit',
    片区入库删除: 'projectUpdate::inventoryReview::area::delete',
    片区入库详情: 'projectUpdate::inventoryReview::area::detail',
    片区入库通过: 'projectUpdate::inventoryReview::area::pass',
    片区入库退回: 'projectUpdate::inventoryReview::area::back',
    片区入库变更: 'projectUpdate::inventoryReview::area::change',
    片区入库审核: 'projectUpdate::inventoryReview::area::audit',
  },
  '9848da564e89476da9c2f91a6a55106f': {
    项目入库新增: 'projectUpdate::inventoryReview::project::add',
    项目入库编辑: 'projectUpdate::inventoryReview::project::edit',
    项目入库删除: 'projectUpdate::inventoryReview::project::delete',
    项目入库详情: 'projectUpdate::inventoryReview::project::detail',
    项目入库通过: 'projectUpdate::inventoryReview::project::pass',
    项目入库退回: 'projectUpdate::inventoryReview::project::back',
    项目入库变更: 'projectUpdate::inventoryReview::project::change',
    项目入库审核: 'projectUpdate::inventoryReview::project::audit',
  },
  '587a67a7608a4cdeaaf33472d5581ab9': {
    子项目入库新增: 'projectUpdate::inventoryReview::subProject::add',
    子项目入库编辑: 'projectUpdate::inventoryReview::subProject::edit',
    子项目入库删除: 'projectUpdate::inventoryReview::subProject::delete',
    子项目入库详情: 'projectUpdate::inventoryReview::subProject::detail',
  },
  '1b3602f86ccc46a2ac9deb84517372f3': {
    项目库管理详情: 'projectUpdate::libraryManagement::detail',
    项目库管理编辑: 'projectUpdate::libraryManagement::edit',
  },
  '327b023f552c4a5095d591f4df81afd1': {
    总台账详情: 'projectUpdate::projectLedger::general::detail',
  },
  fe8be851b19340588d315953086e67e4: {
    入统台账详情: 'projectUpdate::projectLedger::unified::detail',
  },
  '9096a2fa51e643f195d6bfd55720f5a8': {
    金融台账详情: 'projectUpdate::projectLedger::financial::detail',
  },
}

const url = 'http://127.0.0.1:8080/city/api/resource/datacatalog/addDataCatalog'

const addMenuTree = (data) => {
  const params = data
  const paramsObj = new URLSearchParams()
  Object.keys(params).forEach((key) => {
    paramsObj.append(key, params[key])
  })
  const _url = `${url}?${paramsObj.toString()}`
  return fetch(_url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'AUTH-TOKEN':
        'Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiLph43luoYiLCJqdGkiOiJkMDRiMmYzNi02NDc0LTQ3N2YtYmM1YS1jYjA1YzlhZjUwNTIiLCJpYXQiOjE3MzA0Njk0OTQsImV4cCI6MTczMDQ5ODI5NH0.1h5ZheyDWmfZmiW1nIcwEQqNtENdc0w1ltMd7kxRq1A',
    },
  }).then((res) => res.json())
}

Object.keys(obj).forEach((key) => {
  const value = obj[key]
  Object.keys(value).forEach((k) => {
    const item = value[k]
    // 取k的最后两位 比如金融台账详情取到详情
    const name = k.slice(-2)
    // console.log(key, k)
    const obj = {
      catalogType: 0,
      parentId: key,
      catalogName: name,
      icon: '',
      orderIndex: 0,
      status: 1,
      address: item,
      choosePicture: '',
    }
    console.log(obj)
    addMenuTree(obj)
      .then((res) => {
        console.log(res)
      })
      .catch((e) => {
        console.log(e)
      })
  })
})
